//		/\_ \                      /\ \                 
//		\//\ \     ___      __     \_\ \     __   _ __  
//		  \ \ \   / __`\  /'__`\   /'_` \  /'__`\/\`'__\
//		   \_\ \_/\ \_\ \/\ \_\.\_/\ \_\ \/\  __/\ \ \/ 
//		   /\____\ \____/\ \__/.\_\ \___,_\ \____\\ \_\ 
//		   \/____/\/___/  \/__/\/_/\/__,_ /\/____/ \/_/

	dae.removeEventListener(FileLoadEvent.LOAD_COMPLETE, daeLoader);
	
	//MATERIALS
	var huisTrijnBit:Bitmap 			= new huisTrijnClass() as Bitmap;
	var bmpHuisTrijn:BitmapMaterial 	= new BitmapMaterial( huisTrijnBit.bitmapData );
	bmpHuisTrijn.interactive			= true;
	
	var domHighBit:Bitmap 				= new domHighClass() as Bitmap;
	var bmpDom:BitmapMaterial 			= new BitmapMaterial( domHighBit.bitmapData );
	bmpDom.interactive 					= true;
	
	var domKerkBit:Bitmap 				= new domKerkClass() as Bitmap;
	var bmpDomKerk:BitmapMaterial 		= new BitmapMaterial( domKerkBit.bitmapData );
	bmpDomKerk.interactive
	
	var vredenburgHighBit:Bitmap 		= new vredenburgHighClass() as Bitmap;
	var bmpvredenburgHigh:BitmapMaterial= new BitmapMaterial( vredenburgHighBit.bitmapData );
	bmpvredenburgHigh.interactive		= true;
	
	var schatBit:Bitmap 				= new schatClass() as Bitmap;
	var bmpSchat:BitmapMaterial 		= new BitmapMaterial( schatBit.bitmapData );
	bmpSchat.interactive 				= true;
	
	var tvBit:Bitmap 					= new tvClass() as Bitmap;
	var bmptv:BitmapMaterial 			= new BitmapMaterial( tvBit.bitmapData );
	bmptv.interactive 					= true;
	
	var tvOnBit:Bitmap 					= new tvOnClass() as Bitmap;
	var bmptvOn:BitmapMaterial 			= new BitmapMaterial( tvOnBit.bitmapData );
	bmptvOn.interactive 				= true;
	
	var omroeperBit:Bitmap 				= new omroeperClass() as Bitmap;
	var bmpomroeper:BitmapMaterial 		= new BitmapMaterial( omroeperBit.bitmapData );
	bmpomroeper.interactive 			= true;
	
	var karelPlaneBit:Bitmap 			= new karelPlaneClass() as Bitmap;
	var bmpKarelPlane:BitmapMaterial	= new BitmapMaterial( karelPlaneBit.bitmapData );
	bmpKarelPlane.interactive 			= true;
	
	var trijnPlaneBit:Bitmap 			= new trijnPlaneClass() as Bitmap;
	var bmpTrijnPlane:BitmapMaterial	= new BitmapMaterial( trijnPlaneBit.bitmapData );
	bmpTrijnPlane.interactive 			= true;


	//PLANES SETUP
	helper		= new Plane( bmpSchat, 1, 1, 0, 0 );
	karelPlane	= new Plane( bmpKarelPlane, 730, 1820, 1, 1 );
	trijnPlane	= new Plane( bmpTrijnPlane, 205, 450, 1, 1 );

	karelPlane.name = "Karel V";
	//karelPlane.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, Hover_objectClickHandler );
	//karelPlane.addEventListener( InteractiveScene3DEvent.OBJECT_OVER, onObjectHover );
	//karelPlane.addEventListener( InteractiveScene3DEvent.OBJECT_OUT, offObjectHover );
	karelPlane.name = "Trijn";
	//trijnPlane.addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, Hover_objectClickHandler );
	//trijnPlane.addEventListener( InteractiveScene3DEvent.OBJECT_OVER, onObjectHover );
	//trijnPlane.addEventListener( InteractiveScene3DEvent.OBJECT_OUT, offObjectHover );

	//VIEWPORT FILTER
	outline = new GlowFilter( 0x000000, 1, 8, 8, 12, 1, false, false );
	XYZWindow.view.viewport.filters = [outline];

	//MODELS SETUP
	for ( var i:Number = 0; i < aantalAssets; i++ )
	{
		daeModel[i] = dae.getChildByName( "asset_" + i, true );
		daeModel[i].scale = -1;
		daeModel[i].rotationX = 90;
		daeModel[i].y = -5;
		//daeModel[i].addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, Hover_objectClickHandler );
		//daeModel[i].addEventListener( InteractiveScene3DEvent.OBJECT_OVER, onObjectHover );
		//daeModel[i].addEventListener( InteractiveScene3DEvent.OBJECT_OUT, offObjectHover );
	}
	
	daeModel[0].name = "Vredenburg";
	daeModel[1].name = "de Dom Toren";
	daeModel[2].name = "de Dom Kerk";
	daeModel[3].name = "het huis van Trijn";

	daeModel[0].material = bmpvredenburgHigh;
	daeModel[1].material = bmpDom;
	daeModel[2].material = bmpDomKerk;
	daeModel[3].material = bmpHuisTrijn;
	
	//SCHATTEN SETUP
	for ( var j1:Number = 0; j1 < aantalSchatten; j1++ )
	{
		deSchatten[j1] = dae.getChildByName( "schat_" + j1, true );
		deSchatten[j1].scale = -1;
		deSchatten[j1].rotationX = 90;
		deSchatten[j1].y = 0;
		
		var radius1:Number = new Number( vrdnbrgOffset.r - 300 ) - ( Math.random() * 50 );
		var angle1:Number = new Number( Math.PI * 0.25 ) + ( j1 * ( Math.PI * 1.5 / aantalSchatten ) );
		deSchatten[j1].x = vrdnbrgOffset.x + ( Math.sin( angle1 ) * radius1 );
		deSchatten[j1].z = vrdnbrgOffset.z + ( Math.cos( angle1 ) * radius1 );
		
		deSchatten[j1].addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler );
		deSchatten[j1].addEventListener( InteractiveScene3DEvent.OBJECT_OVER, onObjectHover );
		deSchatten[j1].addEventListener( InteractiveScene3DEvent.OBJECT_OUT, offObjectHover );

		deSchatten[j1].material = bmpSchat;
	}
	//FILMPJES SETUP
	for ( var j2:Number = 0; j2 < aantalFilmpjes; j2++ )
	{
		deFilmpjes[j2] = dae.getChildByName( "film_" + j2, true );
		deFilmpjes[j2].scale = -1;
		deFilmpjes[j2].rotationX = 90;
		deFilmpjes[j2].rotationY = 180 + ( j2 * ( 360 / aantalFilmpjes ) );
		deFilmpjes[j2].y = 0;
		
		var radius2:Number = new Number( ( domOffset.r - 300 ) - ( Math.random() * 50 ) );
		var angle2:Number = new Number( j2 * ( Math.PI * 2 / aantalFilmpjes ) );
		deFilmpjes[j2].x = domOffset.x + ( Math.sin( angle2 ) * radius2 );
		deFilmpjes[j2].z = domOffset.z + ( Math.cos( angle2 ) * radius2 );
		
		deFilmpjes[j2].addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler );
		deFilmpjes[j2].addEventListener( InteractiveScene3DEvent.OBJECT_OVER, onObjectHover );
		deFilmpjes[j2].addEventListener( InteractiveScene3DEvent.OBJECT_OUT, offObjectHover );
		
		deFilmpjes[j2].material = bmptv;
	}
	deFilmpjes[0].material = bmptvOn;
	//PLAATJES SETUP
	for ( var j3:Number = 0; j3 < aantalPlaatjes; j3++ )
	{
		dePlaatjes[j3] = dae.getChildByName( "plaat_" + j3, true );
		dePlaatjes[j3].scale = -1;
		dePlaatjes[j3].rotationX = 90;
		dePlaatjes[j3].rotationY = 180 + ( j3 * ( 360 / aantalPlaatjes ) );
		dePlaatjes[j3].y = 0;
		
		var radius3:Number = new Number( ( trijnOffset.r - 300 ) - ( Math.random() * 50 ) );
		var angle3:Number = new Number( j3 * ( Math.PI * 2 / aantalPlaatjes ) );
		dePlaatjes[j3].x = trijnOffset.x + ( Math.sin( angle3 ) * radius3 );
		dePlaatjes[j3].z = trijnOffset.z + ( Math.cos( angle3 ) * radius3 );
		
		dePlaatjes[j3].addEventListener( InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler );
		dePlaatjes[j3].addEventListener( InteractiveScene3DEvent.OBJECT_OVER, onObjectHover );
		dePlaatjes[j3].addEventListener( InteractiveScene3DEvent.OBJECT_OUT, offObjectHover );
		
		dePlaatjes[j3].material = bmpomroeper;
	}
	
	//PEOPLE SETUP
	karelPlane.x = 0;
	karelPlane.z = 0;
	karelPlane.y = 600;
	trijnPlane.x = 4200;
	trijnPlane.z = -4000;
	trijnPlane.y = 150;
	
	
	//SCENE SETUP///////
	//REMOVE ALL MODELS
	for each( var child:DisplayObject3D in XYZWindow.view.scene.children )
		XYZWindow.view.scene.removeChild( child );
		
	//ADD PLANES
	XYZWindow.view.scene.addChild( helper );
	XYZWindow.view.scene.addChild( karelPlane );
	
	//ADD MODELS VOOR VREDENBURG
	XYZWindow.view.scene.addChild( daeModel[0] );
	
	//ADD OBJECTEN VOOR VREDENBURG
	aantalObjecten = aantalSchatten;
	for ( var k1:Number = 0; k1 < aantalObjecten; k1++ )
		deObjecten[k1] = deSchatten[k1];
	for ( var k2:Number = 1; k2 < aantalObjecten; k2++ )
		XYZWindow.view.scene.addChild( deObjecten[k2] );
		
		
		
		
		
		
		